package com.lwj.liwanjia.view.activity.work.shang_jia.ding_dan;

import android.graphics.Color;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.lwj.liwanjia.R;
import com.lwj.liwanjia.adapter.DingDanAllAdapter;
import com.lwj.liwanjia.adapter.DingDanDaiFaHuoAdapter;
import com.lwj.liwanjia.adapter.DingDanYiFaHuoAdapter;
import com.lwj.liwanjia.base.BaseActivity;
import com.lwj.liwanjia.bean.DingDanDaiFaHuoBean;
import com.lwj.liwanjia.bean.DingDanAllBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 001 on 2017/9/16.
 */

public class DingDanHome01Activity extends BaseActivity implements View.OnClickListener {

    private TextView tv_back;
    private TextView tv_title;
    private TextView tv_quanBu;//全部
    private TextView tv_daiFaHuo;//待发货
    private TextView tv_yiFaHuo;//已发货
    private TextView tv_yiQuXiao;//已取消
    private TextView tv_yiWanCheng;//已完成
    private RecyclerView mRecyclerView;
    private DingDanAllAdapter allAdapter;//全部 适配器
    private List<DingDanAllBean> allList;//全部 数据
    private List<DingDanDaiFaHuoBean> daiFaHuoList;//待发货 数据
    private DingDanDaiFaHuoAdapter daiFaHuoAdapter;//待发货 适配器
    private DingDanYiFaHuoAdapter yiFaHuoAdapter;//已发货 适配器
    private List<DingDanDaiFaHuoBean> yiFaHuoList;//已发货 数据

    @Override
    protected void initView() {


        tv_back = (TextView) findViewById(R.id.tv_left);
        tv_title = (TextView) findViewById(R.id.tv_title);
        tv_quanBu = (TextView) findViewById(R.id.tv_quanBu);
        tv_daiFaHuo = (TextView) findViewById(R.id.tv_daiFaHuo);
        tv_yiFaHuo = (TextView) findViewById(R.id.tv_yiFaHuo);
        tv_yiQuXiao = (TextView) findViewById(R.id.tv_yiQuXiao);
        tv_yiWanCheng = (TextView) findViewById(R.id.tv_yiWanCheng);
        mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);

        tv_back.setVisibility(View.VISIBLE);
        tv_title.setVisibility(View.VISIBLE);
        tv_title.setText("商家订单");

        tv_back.setOnClickListener(this);
        tv_quanBu.setOnClickListener(this);
        tv_daiFaHuo.setOnClickListener(this);
        tv_yiFaHuo.setOnClickListener(this);
        tv_yiQuXiao.setOnClickListener(this);
        tv_yiWanCheng.setOnClickListener(this);

    }

    @Override
    protected void initData() {

        //全部 假数据 适配器
        initOkHttpAll();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_ding_dan_home_01;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            //返回
            case R.id.tv_left:
                finish();
                break;
            //全部
            case R.id.tv_quanBu:

                //更改UI
                tv_quanBu.setTextColor(Color.parseColor("#EC921A"));
                tv_daiFaHuo.setTextColor(Color.GRAY);
                tv_yiFaHuo.setTextColor(Color.GRAY);
                tv_yiQuXiao.setTextColor(Color.GRAY);
                tv_yiWanCheng.setTextColor(Color.GRAY);

                initOkHttpAll();

                break;
            //待发货
            case R.id.tv_daiFaHuo:

                //更改UI
                tv_quanBu.setTextColor(Color.GRAY);
                tv_daiFaHuo.setTextColor(Color.parseColor("#EC921A"));
                tv_yiFaHuo.setTextColor(Color.GRAY);
                tv_yiQuXiao.setTextColor(Color.GRAY);
                tv_yiWanCheng.setTextColor(Color.GRAY);

                initOkHttpDaiFaHuo();

                break;
            //已发货
            case R.id.tv_yiFaHuo:

                //更改UI
                tv_quanBu.setTextColor(Color.GRAY);
                tv_daiFaHuo.setTextColor(Color.GRAY);
                tv_yiFaHuo.setTextColor(Color.parseColor("#EC921A"));
                tv_yiQuXiao.setTextColor(Color.GRAY);
                tv_yiWanCheng.setTextColor(Color.GRAY);

                initOkHttpYiFaHuo();

                break;
            //已取消
            case R.id.tv_yiQuXiao:

                //更改UI
                tv_quanBu.setTextColor(Color.GRAY);
                tv_daiFaHuo.setTextColor(Color.GRAY);
                tv_yiFaHuo.setTextColor(Color.GRAY);
                tv_yiQuXiao.setTextColor(Color.parseColor("#EC921A"));
                tv_yiWanCheng.setTextColor(Color.GRAY);

                initOkHttpDaiFaHuo();

                break;
            //已完成
            case R.id.tv_yiWanCheng:

                //更改UI
                tv_quanBu.setTextColor(Color.GRAY);
                tv_daiFaHuo.setTextColor(Color.GRAY);
                tv_yiFaHuo.setTextColor(Color.GRAY);
                tv_yiQuXiao.setTextColor(Color.GRAY);
                tv_yiWanCheng.setTextColor(Color.parseColor("#EC921A"));

                initOkHttpDaiFaHuo();

                break;
        }
    }

    //全部 假数据 适配器
    private void initOkHttpAll() {

        allList = new ArrayList<>();

        for (int i = 0; i < 20; i++) {

            DingDanAllBean bean = new DingDanAllBean();
            bean.url = "http://p1.4499.cn/touxiang/uploadpic/2012-7/12/2012071213284257385.jpg";
            allList.add(bean);

            DingDanAllBean bean02 = new DingDanAllBean();
            bean02.url = "http://dynamic-image.yesky.com/300x-/uploadImages/upload/20140902/upload/201409/0eeor003vrppng.png";
            allList.add(bean02);

            DingDanAllBean bean03 = new DingDanAllBean();
            bean03.url = "http://img4.duitang.com/uploads/item/201601/03/20160103213604_8VPry.jpeg";
            allList.add(bean03);

        }

        LinearLayoutManager manager = new LinearLayoutManager(this);
        mRecyclerView.setLayoutManager(manager);
        allAdapter = new DingDanAllAdapter(this, allList);
        mRecyclerView.setAdapter(allAdapter);
    }

    //待发货 假数据 适配器
    private void initOkHttpDaiFaHuo() {

        daiFaHuoList = new ArrayList<>();

        for (int i = 0; i < 20; i++) {

            DingDanDaiFaHuoBean bean = new DingDanDaiFaHuoBean();
            bean.photoUrl = "http://m.3fantizi.com/Article/pic/2014118123633518.jpg";
            bean.imageUrl = "https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=2381786565,94940444&fm=27&gp=0.jpg";
            daiFaHuoList.add(bean);

            DingDanDaiFaHuoBean bean02 = new DingDanDaiFaHuoBean();
            bean02.photoUrl = "http://www.qqpk.cn/Article/UploadFiles/201009/20100915164919920.jpg";
            bean02.imageUrl = "https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=1338434881,1355452642&fm=27&gp=0.jpg";
            daiFaHuoList.add(bean02);

            DingDanDaiFaHuoBean bean03 = new DingDanDaiFaHuoBean();
            bean03.photoUrl = "http://img1.imgtn.bdimg.com/it/u=671157224,1160825183&fm=27&gp=0.jpg";
            bean03.imageUrl = "https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1771007858,3227012830&fm=27&gp=0.jpg";
            daiFaHuoList.add(bean03);
        }

        LinearLayoutManager manager = new LinearLayoutManager(this);
        mRecyclerView.setLayoutManager(manager);
        daiFaHuoAdapter = new DingDanDaiFaHuoAdapter(this, daiFaHuoList);
        mRecyclerView.setAdapter(daiFaHuoAdapter);
    }

    //已发货 假数据 适配器
    private void initOkHttpYiFaHuo() {

        yiFaHuoList = new ArrayList<>();

        for (int i = 0; i < 20; i++) {

            DingDanDaiFaHuoBean bean = new DingDanDaiFaHuoBean();
            bean.photoUrl = "http://m.3fantizi.com/Article/pic/2014118123633518.jpg";
            bean.imageUrl = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1506147774&di=4679dcdeaac84bb29c75eeca160128f2&imgtype=jpg&er=1&src=http%3A%2F%2Fimg000.hc360.cn%2Fy2%2FM04%2FA8%2F2D%2FwKhQdFR9gCKEKzJLAAAAAEuuiv0842.jpg";
            yiFaHuoList.add(bean);

            DingDanDaiFaHuoBean bean02 = new DingDanDaiFaHuoBean();
            bean02.photoUrl = "http://www.qqpk.cn/Article/UploadFiles/201009/20100915164919920.jpg";
            bean02.imageUrl = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1506147794&di=e6f0822d732a4f83a8d8eca52a35957a&imgtype=jpg&er=1&src=http%3A%2F%2Fimg004.hc360.cn%2Fg8%2FM08%2F01%2FD8%2FwKhQtVQJ8qeEI3LGAAAAAKyyvfo991.jpg";
            yiFaHuoList.add(bean02);

            DingDanDaiFaHuoBean bean03 = new DingDanDaiFaHuoBean();
            bean03.photoUrl = "http://img1.imgtn.bdimg.com/it/u=671157224,1160825183&fm=27&gp=0.jpg";
            bean03.imageUrl = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1506147807&di=2a968001d6ac3d2e261f348024b1cd59&imgtype=jpg&er=1&src=http%3A%2F%2Fimg006.hc360.cn%2Fm3%2FM04%2FD7%2F1F%2FwKhQ5lSqUCiEd8bRAAAAAFv75pk441.jpg";
            yiFaHuoList.add(bean03);
        }

        LinearLayoutManager manager = new LinearLayoutManager(this);
        mRecyclerView.setLayoutManager(manager);
        yiFaHuoAdapter = new DingDanYiFaHuoAdapter(this, yiFaHuoList);
        mRecyclerView.setAdapter(yiFaHuoAdapter);
    }

    //已取消 假数据 适配器

    //已完成 假数据 适配器
}
